import instacne from "../request";
import * as qs from 'qs';
// 营销活动的相关数据 /flash/list
export const flashListInfo = (params: {
    pageNum: number,
    pageSize: number,
    keyword?: string
}): Promise<{  
    list: any[],
    pageSize: number,
    pageNum: number,
    [type: string]: any
}> => instacne.get(`/flash/list`, { params })

// 删除活动操作 /mall-admin/flash/delete/{id}
export const FlashDelete = (params: {
    id: string
}) => instacne.post(`/flash/delete/${params.id}`)

//添加活动信息/mall-admin/flash/create
export const FlashCreate = (params: any) => instacne.post(`/flash/create`, params)
// 秒杀活动相关的两个页面的数据展示请求


// 1. 获取活动详情 根据id /flashSession/selectList 获取全部可选场次及其数量 
export const flashID = (id:string) => instacne.get(`/flashSession/selectList?flashPromotionId=${id}`)
// 2. 获取全部场次/flashSession/list 获取全部场次
export const allFlashSession = ()=> instacne.get('flashSession/list')
// 3. 删除某一条数据 /flashSession/delete/{id}
export const deleteFlashSession = (id : number) =>instacne.post(`/flashSession/delete/${id}`)



//优惠券列表全部   根据多个信息 搜索也是在这里进行 /coupon/list 
export const couponList = (params: {
    name?: string,
    pageNum?: number,
    pageSize?: number,
    type?: string
}): Promise<any> => instacne.get('/coupon/list', { params })


// 删除优惠券/coupon/delete/{id}
export const deleteCupon = (id: number) => instacne.post(`/coupon/delete/${id}`)

// 获取单个优惠券的详细信息/coupon/{id}
export const getOneCupon = (id: any):any => instacne.get(`/coupon/${id}`)

///mall-admin/couponHistory/list 根据优惠券id，使用状态，订单编号分页获取领取记录
export const couponHistoryList = (params: {
    couponId?: any,
    orderSn?: any,
    pageNum: number,
    pageSize: number,
    useStatus?: any
}): Promise<{
    list: Array<any>,
    pageNum: number,
    pageSize: number,
    totalPage: number
}> => instacne.get('/couponHistory/list', { params })

//  修改优惠券 /coupon/update/{id}
export const updateCoupon = (id: number): Promise<any> => instacne.get(`/coupon/update/${id}`)

// 品牌推荐区 
//  home/brand/list   获取列表
export const brandListComment = (params: {
    brandName?: string,
    pageNum: number,
    pageSize: number,
    recommendStatus?: number
}): Promise<any> => instacne.get('/home/brand/list', { params })

// 删除某一条数据 /home/brand/delete ids 批量
export const deleteList = (ids: string) => instacne.post(`/home/brand/delete`, qs.stringify({ ids: ids }))

// 修改推荐状态 /home/brand/update/recommendStatus  批量
export const updateRecommendStatus = (params: {
    ids: number | Array<number> | string,
    recommendStatus: number
}) => instacne.post('/home/brand/update/recommendStatus', qs.stringify({ ids: params.ids, recommendStatus: params.recommendStatus }))
// 修改推荐排序   /home/brand/update/sort/{id}
export const brandChangeSort = (params: {
    sort: number | string,
    id: number
}) => instacne.post(`/home/brand/update/sort/${params.id}`, qs.stringify({ sort: params.sort }))



// 新品 -----
//  home/newProduct/list  获取列表
export const newProductListComment = (params: {
    brandName?: string,
    pageNum: number,
    pageSize: number,
    recommendStatus?: number
}): Promise<any> => instacne.get('/home/newProduct/list', { params })

// 删除某一条数据 /home/brand/delete ids 批量
export const deleteProductList = (ids: string) => instacne.post(`/home/newProduct/delete`, qs.stringify({ ids: ids }))
// 修改推荐状态/home/newProduct/update/recommendStatus  批量
export const updatenewProductStatus = (params: {
    ids: number | Array<number> | string,
    recommendStatus: number
}) => instacne.post('/home/newProduct/update/recommendStatus', qs.stringify({ ids: params.ids, recommendStatus: params.recommendStatus }))
// 修改推荐排序  /home/newProduct/update/sort/{id}
export const newProductChangeSort = (params: {
    sort: number | string,
    id: number
}) => instacne.post(`/home/newProduct/update/sort/${params.id}`, qs.stringify({ sort: params.sort }))



// 人气
//  home/recommendProduct/list   获取列表
export const recommendProductList = (params: {
    brandName?: string,
    pageNum: number,
    pageSize: number,
    recommendStatus?: number
}): Promise<any> => instacne.get('/home/recommendProduct/list', { params })

// 删除某一条数据 /home/brand/delete ids 批量
export const deleteRecommendProductList = (ids: string) => instacne.post(`/home/recommendProduct/delete`, qs.stringify({ ids: ids }))
// 修改推荐状态 /home/recommendProduct/update/recommendStatus  批量
export const updaterecommendProductStatus = (params: {
    ids: number | Array<number> | string,
    recommendStatus: number
}) => instacne.post('/home/recommendProduct/update/recommendStatus', qs.stringify({ ids: params.ids, recommendStatus: params.recommendStatus }))
// 修改推荐排序   /home/recommendProduct/update/sort/{id}
export const recommendProductChangeSort = (params: {
    sort: number | string,
    id: number
}) => instacne.post(`/home/recommendProduct/update/sort/${params.id}`, qs.stringify({ sort: params.sort }))



//专题
//  /home/recommendSubject/list   获取列表
export const brandRecommendSubjectList = (params: {
    brandName?: string,
    pageNum: number,
    pageSize: number,
    recommendStatus?: number
}): Promise<any> => instacne.get('/home/recommendSubject/list', { params })

// 删除某一条数据 /home/brand/delete ids 批量
export const deleteRecommendSubjectList = (ids: string) => instacne.post(`/home/recommendSubject/delete`, qs.stringify({ ids: ids }))
// 修改推荐状态 /home/recommendSubject/update/recommendStatus  批量
export const updaterecommendSubject = (params: {
    ids: number | Array<number> | string,
    recommendStatus: number
}) => instacne.post('/home/recommendSubject/update/recommendStatus', qs.stringify({ ids: params.ids, recommendStatus: params.recommendStatus }))
// 修改推荐排序  /home/recommendSubject/update/sort/{id}
export const recommendSubjectChangeSort = (params: {
    sort: number | string,
    id: number
}) => instacne.post(`/home/recommendSubject/update/sort/${params.id}`, qs.stringify({ sort: params.sort }))



// 广告列表 /home/advertise/list 获取列表   
export const AdvertiseList = (params: {
    pageSize?: number,
    pageNum?: number,
    endTime?: string,
    name?: string
    type?: number
}):any => instacne.get('/home/advertise/list',{params})
// /home/advertise/update/status/{id} 修改上下线状态
export const AdvertiseUpdateStatus = (params : {
    id : number|string,
    status : number
})=>instacne.post(`/home/advertise/update/status/${params.id}`,qs.stringify({status : params.status}))
//   /home/advertise/delete  删除广告
export const AdvertiseDelete = (ids : string)=> instacne.post('/home/advertise/delete',qs.stringify({ids : ids}))
// /home/advertise/{id} 获取广告详情
export const updateAdvertise = (id:number):Promise<any>=>instacne.get(`/home/advertise/${id}`)
// /home/advertise/update/{id}  修改广告
export const changeUpdateAdvertise = (params : {
    id : number
    advertise  : any
})=>instacne.post(`/home/advertise/update/${params.id}`,qs.stringify({advertise : params.advertise}))